'libtgfx - Threaded Graphics library for FreeBASIC
'Copyright (C) 2013  Ebben Feagan <sir@mud.owlbox.net>
'
'This library is free software; you can redistribute it and/or
'modify it under the terms of the GNU Lesser General Public
'License as published by the Free Software Foundation; either
'version 2.1 of the License, or (at your option) any later version.
'
'This library is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
'Lesser General Public License for more details.
'
'You should have received a copy of the GNU Lesser General Public
'License along with this library; if not, write to the Free Software
'Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#include once "tgfx.bi"
#include once "tgfx-priv.bi"

namespace tgfx.keys

    function pressed( byval scncode as KeyCode ) as tgfx.bool export

        var cc = new CommChannel()

        Comm->send( new Message(_MKEYG,new MData(new int_data(scncode),@null_free), cc ) )
        var ret = cc->recv()
        while ret = 0
            sleep 1,1
            ret = cc->recv()
        wend

        if ret->c = _MTRUE then
            delete ret
            delete cc
            return true
        end if

        delete cc
        delete ret

        return tgfx.false

    end function

end namespace
